﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//using BattleCore;
using BattleCore.Events;
//using PsyModules;

namespace Battle
{
    public class RegionControl
    {
        private class Region
        {
            private RegionType _Type;
            public RegionType Type { get { return _Type; } }

            private ushort[] _Location = new ushort[4];
            public ushort[] Location { get { return _Location; } }

            public Region(RegionType Type, ushort[] Location)
            {
                this._Type = Type;
                this._Location = Location;
            }
        }

        private List<Region> _MasterList = new List<Region>();

        public void AddRegion(RegionType Type, ushort[] Location)
        {
            _MasterList.Add(new Region(Type, Location));
        }
        public RegionType GetRegion(PlayerPositionEvent p)
        {
            for (int i = 0; i < _MasterList.Count; i++)
            {
                if (inRegion(p, _MasterList[i].Location))
                    return _MasterList[i].Type;
            }
            return RegionType.NoRegion;
        }
        // Collision code
        private bool inRegion(PlayerPositionEvent p, ushort[] Box)
        {
            if (p.MapPositionX > Box[0] && p.MapPositionX < Box[2]
                && p.MapPositionY > Box[1] && p.MapPositionY < Box[3])
                return true;
            return false;
        }
    }
}
